package com.gao.handle;

import java.util.Scanner;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class StudentTest {
    public static void main(String[] args) {
        Student2 student2 = new Student2();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = sc.nextLine();
        student2.setName(name);

            System.out.println("请输入年龄:");

            while (true) {
                try {
                    int age = Integer.parseInt(sc.nextLine());
                    student2.setAge(age);
                    break;
                }catch(NumberFormatException e){
                    System.out.println("不是数字，请重新输入");
                }
                catch (Exception e) {
                     String message = e.getMessage();
                    System.out.println(message+",请重新输入");
                }
            }
            System.out.println("请输入数学成绩:");
        while (true) {
            try {
                int math = Integer.parseInt(sc.nextLine());
                student2.setMath(math);
                break;
            } catch (NumberFormatException e) {
                System.out.println("不是数字，请重新输入");
            }catch (Exception e){
                String message = e.getMessage();
                System.out.println(message+",请重新输入");
            }
        }
             System.out.println("请输入英语成绩:");
        while (true) {
            try {
                int english = Integer.parseInt(sc.nextLine());
                student2.setEnglish(english);
                break;
            } catch (NumberFormatException e) {
                System.out.println("不是数字，请重新输入");
            } catch (Exception e){
                String message = e.getMessage();
                System.out.println(message+",请重新输入");
            }
        }
        System.out.println("请输入语文成绩:");
        while (true) {
            try {
                int chinese = Integer.parseInt(sc.nextLine());
                student2.setChinese(chinese);
                break;
            } catch (NumberFormatException e) {
                System.out.println("不是数字，请重新输入");
            }catch (Exception e) {
                String message = e.getMessage();
                System.out.println(message+",请重新输入");
            }
        }
    }


}
